package com.rico.queue.controller;

import com.rico.queue.kafka.KafkaProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@RestController
public class KafkaController {

    @Autowired
    private KafkaProducer kafkaProducer;

    @GetMapping("/sendMessage")
    public void sendMessage(String topic,String msg){
        topic= Optional.of(topic).orElse("default");
        kafkaProducer.sendMessage(topic,msg);
    }
}
